package cn.lutu.domain.repository.impl;

import cn.lutu.dao.mapper.OrderMapper;
import cn.lutu.domain.repository.OrderRepository;
import cn.lutu.protocol.entity.Order;
import cn.lutu.protocol.vo.OrderListVO;
import cn.lutu.protocol.vo.OrderVO;
import cn.lutu.protocol.vo.adminVO.AdminOrderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Slf4j
public class OrderRepositoryImpl implements OrderRepository {
    @Autowired
    OrderMapper orderMapper;


    @Override
    public int deleteById(Long id) {
        log.debug("删除订单数据开始,参数为{}",id);
        return orderMapper.deleteById(id);
    }

    @Override
    public int updateById(Order order) {
        log.debug("更新订单数据开始,参数为{}",order);
        return orderMapper.updateById(order);
    }


    @Override
    public List<OrderVO> selectListOrderByStatus(String status,Long id) {
        log.debug("查看用户订单开始,参数为{},{}",status,id);
        return orderMapper.selectListOrderByStatus(status,id);
    }

    @Override
    public List<OrderVO> selectListOrderByCategoryAndKeyword(Long categoryId, String keyword, Long id) {
        log.debug("搜索用户订单开始,参数为{},{},{}",categoryId,keyword,id);
        return orderMapper.selectListByCategoryAndKeyword(categoryId,keyword,id);
    }

    @Override
    public List<AdminOrderVO> selectAllOrder() {
        log.debug("搜索所有用户订单开始");
        return orderMapper.selectAllOrder();
    }

    @Override
    public List<OrderListVO> list() {
        log.debug("搜索所有用户订单开始");
        return orderMapper.selectOrderList();
    }
}
